set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)

set(_ROOT "$ENV{JESTON_NX_9_3_TOOLCHAIN_PATH}")

set(CMAKE_SYSROOT "$ENV{THIRDPARTY_IN_PC_NX_9_3}/sysroot")
# set(CMAKE_SYSROOT "${_ROOT}/aarch64-buildroot-linux-gnu/sysroot")
set(CMAKE_C_COMPILER "${_ROOT}/bin/aarch64-linux-gcc")
set(CMAKE_CXX_COMPILER "${_ROOT}/bin/aarch64-linux-g++")

set(CMAKE_AR "${_ROOT}/bin/aarch64-linux-gcc-ar" CACHE FILEPATH "Path to ar." FORCE)
set(CMAKE_RANLIB "${_ROOT}/bin/aarch64-linux-gcc-ranlib" CACHE FILEPATH "Path to ranlib." FORCE)

unset(_ROOT)

#use env variable THIRDPARTY_IN_PC_NX as a hint for third_party path
#so we can use this toolchain file in different desktop without change dir everytime
#just need to add "export THIRDPARTY_IN_PC_NX=/you_path" in bashrc file

if(NOT DEFINED ENV{THIRDPARTY_IN_PC_NX_9_3})
   message(FATAL_ERROR "THIRDPARTY_IN_PC_NX_9_3 environment variable not set")
endif()

foreach(DIR ITEMS eigen3 boost1_71_0 gtest opencv4.5.4 vpi2 noetic)
   list(APPEND CMAKE_FIND_ROOT_PATH "$ENV{THIRDPARTY_IN_PC_NX_9_3}/${DIR}")
endforeach()

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
